﻿<StatCalc:StatCalcGadgetBase x:Class="EpiDashboard.Gadgets.StatCalc.PopulationSurveyGadget"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:EpiDashboard="clr-namespace:EpiDashboard"
    xmlns:StatCalc="clr-namespace:EpiDashboard.Gadgets.StatCalc"
    xmlns:toolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=Epi.DataVisualization.Toolkit"
    xmlns:Controls="clr-namespace:EpiDashboard.Controls"
    Style="{DynamicResource gadgetBaseStyle}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../ResourceDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>        
        <Border Name="borderAll" Style="{DynamicResource mainGadgetBorder}" >

            <Grid x:Name="grdMain">
                <Grid.RowDefinitions>
                    <RowDefinition Height="28"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                
                <Controls:CloseButton x:Name="closeButton" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="5" MouseLeftButtonUp="CloseButton_MouseLeftButtonUp"></Controls:CloseButton>
                
                <StackPanel Grid.Row="0" Grid.RowSpan="2" Grid.ColumnSpan="2">
                    <TextBlock HorizontalAlignment="Center" TextAlignment="Center" FontSize="24" Margin="5" FontWeight="Bold">
                        Population survey or descriptive study
                        </TextBlock>

                    <TextBlock HorizontalAlignment="Center" TextAlignment="Center" FontSize="14" Margin="5" FontWeight="Bold">
                        For simple random sampling, leave design effect and clusters equal to 1.
                    </TextBlock>

                    <Grid Height="Auto">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width=".5*" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width=".5*" />
                            <ColumnDefinition Width="10" />
                        </Grid.ColumnDefinitions>
                        <Grid Grid.Column="1" HorizontalAlignment="Center">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="120"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="50"/>
                                <RowDefinition Height="50"/>
                                <RowDefinition Height="50"/>
                                <RowDefinition Height="50"/>
                                <RowDefinition Height="50"/>
                            </Grid.RowDefinitions>
                            <TextBlock VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" TextWrapping="Wrap">Population size:</TextBlock>
                            <TextBox Grid.Row="0" Grid.Column="2" TextAlignment="Right" Height="30" Width="120" HorizontalAlignment="Right" FontFamily="Microsoft Sans Serif"  FontSize="20" x:Name="txtPopulationSize"></TextBox>
                            <TextBlock VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" TextWrapping="Wrap">Expected frequency:</TextBlock>
                            <StackPanel Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal">
                                <TextBox TextAlignment="Right" Height="30" Width="50" FontFamily="Microsoft Sans Serif" FontSize="20" x:Name="txtExpectedFreq"></TextBox>
                                <TextBlock VerticalAlignment="Center" FontWeight="Black">&#160;%</TextBlock>
                            </StackPanel>
                            <TextBlock VerticalAlignment="Center" Grid.Row="2" Grid.Column="0" TextWrapping="Wrap">Confidence limits:</TextBlock>
                            <StackPanel Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal">
                                <TextBox TextAlignment="Right" Height="30" Width="50" FontFamily="Microsoft Sans Serif" FontSize="20" x:Name="txtConfidenceLimits"></TextBox>
                                <TextBlock VerticalAlignment="Center" FontWeight="Black">&#160;%</TextBlock>
                            </StackPanel>
                            <TextBlock VerticalAlignment="Center" Grid.Row="3" Grid.Column="0" TextWrapping="Wrap">Design effect:</TextBlock>
                            <StackPanel Grid.Row="3" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal">
                                <TextBox TextAlignment="Right" Height="30" Width="50" FontFamily="Microsoft Sans Serif" FontSize="20" x:Name="txtDesignEffect" Grid.Column="1" Margin="66,9,14,11" Grid.Row="3"></TextBox>
                            </StackPanel>
                            <TextBlock VerticalAlignment="Center" Grid.Row="4" Grid.Column="0" TextWrapping="Wrap">Clusters:</TextBlock>
                            <StackPanel Grid.Row="4" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal">
                                <TextBox TextAlignment="Right" Height="30" Width="50" FontFamily="Microsoft Sans Serif" FontSize="20" x:Name="txtNumberOfClusters" Grid.Column="1" Margin="66,9,14,11" Grid.Row="3"></TextBox>
                            </StackPanel>
                        </Grid>
                        <Grid Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="True">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition Width="60" />
                                <ColumnDefinition Width="60" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                            </Grid.RowDefinitions>
                            
                            <Rectangle Grid.Row="0" Grid.Column="0" Style="{DynamicResource gridHeaderCellRectangle}" />
                            <Rectangle Grid.Row="0" Grid.Column="1" Style="{DynamicResource gridHeaderCellRectangle}" />
                            <Rectangle Grid.Row="0" Grid.Column="2" Style="{DynamicResource gridHeaderCellRectangle}" />
                            
                            <Border Grid.Row="0" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="0" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="0" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>

                            <Border Grid.Row="1" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="2" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="3" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="4" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="5" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="6" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="7" Grid.Column="0" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,1"></Border>                            

                            <Border Grid.Row="1" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="2" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="3" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="4" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="5" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="6" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,0"></Border>
                            <Border Grid.Row="7" Grid.Column="1" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,0,1"></Border>                            

                            <Border Grid.Row="1" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>
                            <Border Grid.Row="2" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>
                            <Border Grid.Row="3" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>
                            <Border Grid.Row="4" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>
                            <Border Grid.Row="5" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>
                            <Border Grid.Row="6" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,0"></Border>
                            <Border Grid.Row="7" Grid.Column="2" Style="{DynamicResource gridCellBorder}" BorderThickness="1,1,1,1"></Border>

                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="1" FontWeight="Bold">80%</TextBlock>                            
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="2" FontWeight="Bold">90%</TextBlock>                            
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="3" FontWeight="Bold">95%</TextBlock>
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="4" FontWeight="Bold">97%</TextBlock>
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="5" FontWeight="Bold">99%</TextBlock>
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="6" FontWeight="Bold">99.9%</TextBlock>
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="7" FontWeight="Bold">99.99%</TextBlock>
                            <!-- -->
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="0" TextAlignment="Center" FontWeight="Bold" Margin="3" Foreground="White">Confidence<LineBreak />Level</TextBlock>
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="0" TextAlignment="Center" FontWeight="Bold" Margin="3" Foreground="White">Cluster<LineBreak />Size</TextBlock>
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="0" TextAlignment="Center" FontWeight="Bold" Margin="3" Foreground="White">Total<LineBreak />Sample</TextBlock>
                            <!-- -->
                            <TextBlock Name="txt80" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="txt90" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="2" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="txt95" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="3" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="txt97" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="4" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="txt99" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="5" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="txt999" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="6" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="txt9999" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="7" FontWeight="Bold"></TextBlock>
                            
                            <TextBlock Name="ttxt80" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="1" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="ttxt90" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="2" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="ttxt95" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="3" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="ttxt97" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="4" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="ttxt99" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="5" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="ttxt999" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="6" FontWeight="Bold"></TextBlock>                            
                            <TextBlock Name="ttxt9999" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="7" FontWeight="Bold"></TextBlock>
                        </Grid>
                    </Grid>
                </StackPanel>
                
                <StackPanel Grid.Row="7" x:Name="panelMain" HorizontalAlignment="Left" VerticalAlignment="Top"></StackPanel>
                
            </Grid>
        </Border>        
    </Grid>
</StatCalc:StatCalcGadgetBase>
